<h3 class="text-danger text-bold text-center">分组、域名、属性、修改，都同步更新到推广模板，请慎重修改！</h3>
@if(auth()->user()->id === 1)
<div class="form-group">
    <label for="tagUid" class="col-md-3 control-label">所属用户</label>
    <div class="col-md-5">
        <select class="form-control" name="uid" id="tagUid"
                onchange="$('#username').val($(this).find('option:selected').text());">
            @foreach ($userList as $id=>$name)
                <option value="{{ $id }}" @if ($id === $uid) selected="selected" @endif>{{ $name }}</option>
            @endforeach
        </select>
        <input type="hidden" id="username" name="username" value="{{ empty($username) ? $userList[1] : $username}}">
    </div>
</div>
@else
    <input type="hidden" id="uid" name="uid" value="{{auth()->user()->id}}">
    <input type="hidden" id="username" name="username" value="{{auth()->user()->name}}">
@endif

<div class="form-group">
    <label for="tagGid" class="col-md-3 control-label">所属分组</label>
    <div class="col-md-5">
        <select class="form-control" name="gid" id="tagGid"
                onchange="inputForWrite(this)">
            @foreach ($groupList as $row)
                <option tpl_id="{{$row['tpl_id']}}" template="{{ $row['template'] }}" target_gid="{{ $row['target_gid'] }}" target_gname="{{ $row['target_gname'] }}"
                        directory="{{ $row['directory'] }}" go_to_type="{{ $row['go_to_type'] }}"
                        go_to_type_title="{{ $row['go_to_type_title'] }}" username="{{ $row['username'] }}"
                        value="{{ $row['id'] }}"
                        @if ($row['id'] === $gid) selected="selected" @endif>{{ $row['title'] }}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="form-group">
    <label for="tagDomain" class="col-md-3 control-label">域名</label>
    <div class="col-md-5">
        <textarea class="form-control" rows="3" name="domain" id="tagDomain">{{ $domain }}</textarea>
    </div>
</div>
<div class="form-group">
    <label for="tagDirection" class="col-md-3 control-label">分组目录</label>
    <div class="col-md-5">
        <input type="text" class="form-control" name="directory" id="tagDirection"
               value="{{ empty($directory)? $groupList[0]['directory']:$directory }}" readonly>
    </div>
</div>
<div class="form-group">
    <label for="tagGoToTypeTitle" class="col-md-3 control-label">跳转类型
    </label>
    <div class="col-md-5">
        <input type="text" class="form-control" name="go_to_type_title" id="tagGoToTypeTitle"
               value="{{ empty($go_to_type_title)? $groupList[0]['go_to_type_title']:$go_to_type_title }}" readonly>
			
        <input type="hidden" id="target_gid" name="target_gid" value="{{ empty($target_gid) ? $groupList[0]['target_gid'] : $target_gid}}">
    </div>
</div>
<div class="form-group">
    <label for="tagTargetGname" class="col-md-3 control-label">跳转目标</label>
    <div class="col-md-5">
        <input type="text" class="form-control" name="target_gname" id="tagTargetGname"
               value="{{ empty($target_gname)? $groupList[0]['target_gname']:$target_gname }}" readonly>
    </div>
</div>
<div class="form-group">
    <label for="tagTemplate" class="col-md-3 control-label">渲染模板</label>
    <div class="col-md-5">
        <input type="text" class="form-control" name="template" id="tagTemplate"
               value="{{ empty($template)? $groupList[0]['template']:$template }}" readonly>
        <input type="hidden" class="form-control" name="tpl_id" id="tagTemplateId"
               value="{{ empty($tpl_id)? $groupList[0]['tpl_id']:$tpl_id }}" readonly>
    </div>
</div>

<div class="form-group">
    <label for="access_type" class="col-md-3 control-label">访问类型</label>
    <div class="col-md-5">
        <select class="form-control" name="access_type" id="access_type">
            <option value="http">http</option>
			<option value="https">https</option>
        </select>
    </div>
</div>
{{--<div class="form-group radio">
    <label for="tagTemplate" class="col-md-3 control-label"></label>
	<div class="col-md-5">
         <input type="radio" name="checkBlack" id="checkBlack" value="1" ><label for="checkBlack" class="col-md-4 ">检测域名入库</label>
    </div>
</div>--}}


<div class="form-group">
    <input type="hidden" id="gname" name="gname" value="{{ empty($gname)? $groupList[0]['title']:$gname }}">
    <input type="hidden" id="go_to_type" name="go_to_type"
           value="{{ empty($go_to_type)? $groupList[0]['go_to_type']:$go_to_type }}">
</div>
<script type="text/javascript">
    function inputForWrite(thisObj) {
        $obj = $(thisObj).find('option:selected');
        $('#tagTemplateId').val($obj.attr('tpl_id'));
        $('#tagTemplate').val($obj.attr('template'));
        $('#tagTargetGname').val($obj.attr('target_gname'));
        $('#target_gid').val($obj.attr('target_gid'));

        $('#tagDirection').val($obj.attr('directory'));
        $('#tagGoToTypeTitle').val($obj.attr('go_to_type_title'));
        // hidden
        $('#gname').val($obj.text());
        $('#go_to_type').val($obj.attr('go_to_type'));

    }
</script>
